(Bitwise Shift Left, with Sign)

The Shift Right (with sign) operator is used to shift the binary equivelant of the given integerial number the number of spaces given by the value (which can only be an integer) to the right of the operator. That is, the operator looks at the number which is given on the left of the operator as a 32 bit binary number. This binary number is shifted to the left according to the number (which can only be an integer) to the right of the operator, adding ones or zeros to the right as the furthest numbers on the left are dropped. This new binary number is then converted to a decimal integer and returned as the result of the operation. The decision to add ones or zeros to the number depends upon the sign (negative or positive) of the original number, which must be an integer. If the number is positive, zeros are added. If the number is negative, ones are added.

syntax:

numberOne << numberTwo

EXAMPLE

variableOne = 20 << 2;

document.write("The new value is " + variableOne);

The example shows a variable being declared that uses the shift left operator. The original number given is 20. This number is then converted to its 32 bit binary equivalent. It is then shifted to the left two places. The new number, which is an returned as an integer, is written to the screen with the document.write statement. The value of variableOne is now 80.